<?php /* PROJECTS $Id: do_project_aed.php,v 1.11.10.4 2006/07/25 20:24:13 merlinyoda Exp $ */
$projectsArr = dPgetParam( $_POST, 'checkArchive');
$projectsArr = explode(',', $projectsArr);
require_once($AppUI->getModuleClass('projects'));
$obj = new CProject();

header('Content-Type: text/xml');

$xml = new XmlWriter();
$xml->openMemory();
$xml->startDocument('1.0', 'UTF-8');

$xml->startElement('root');
$i = 0;
foreach($projectsArr as $project_id) {
	$class= $i % 2 == 0 ? "second" : "first";
	$i++;
	if ($obj->load($project_id) === false) {
		$xml->writeElement("log", "Failed to load reference with id: $project_id)");
		continue;
	}
	$msg = $obj->doArchive();
	if ($msg != '') {
		$xml->writeElement("log", "Finish {$obj->project_iso_code} get errors: $msg");
	} else {
		$xml->writeElement("log", "[{$obj->project_id}] {$obj->project_iso_code} has been finished");
	}
}

$xml->endElement();

echo $xml->outputMemory(true);
?>